import 'package:finance_app/src/entities/user_profile_entity.dart';

userProfileEntityFromJson(UserProfileEntity data, Map<String, dynamic> json) {
	if (json['id'] != null) {
		data.id = json['id'] is String
				? int.tryParse(json['id'])
				: json['id'].toInt();
	}
	if (json['data_type'] != null) {
		data.dataType = json['data_type'].toString();
	}
	if (json['name'] != null) {
		data.name = json['name'].toString();
	}
	if (json['email'] != null) {
		data.email = json['email'].toString();
	}
	if (json['country_code'] != null) {
		data.countryCode = json['country_code'].toString();
	}
	if (json['phone_number'] != null) {
		data.phoneNumber = json['phone_number'].toString();
	}
	if (json['locale'] != null) {
		data.locale = json['locale'].toString();
	}
	if (json['timezone'] != null) {
		data.timezone = json['timezone'].toString();
	}
	if (json['avatar'] != null) {
		data.avatar = json['avatar'].toString();
	}
	if (json['default_company_id'] != null) {
		data.defaultCompanyId = json['default_company_id'].toString();
	}
	if (json['notification_token'] != null) {
		data.notificationToken = json['notification_token'].toString();
	}
	if (json['employee_id'] != null) {
		data.employeeId = json['employee_id'] is String
				? int.tryParse(json['employee_id'])
				: json['employee_id'].toInt();
	}
	if (json['show_tutorial'] != null) {
		data.showTutorial = json['show_tutorial'] is String
				? int.tryParse(json['show_tutorial'])
				: json['show_tutorial'].toInt();
	}
	if (json['nickname'] != null) {
		data.nickname = json['nickname'].toString();
	}
	return data;
}

Map<String, dynamic> userProfileEntityToJson(UserProfileEntity entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['id'] = entity.id;
	data['data_type'] = entity.dataType;
	data['name'] = entity.name;
	data['email'] = entity.email;
	data['country_code'] = entity.countryCode;
	data['phone_number'] = entity.phoneNumber;
	data['locale'] = entity.locale;
	data['timezone'] = entity.timezone;
	data['avatar'] = entity.avatar;
	data['default_company_id'] = entity.defaultCompanyId;
	data['notification_token'] = entity.notificationToken;
	data['employee_id'] = entity.employeeId;
	data['show_tutorial'] = entity.showTutorial;
	data['nickname'] = entity.nickname;
	return data;
}